package com.lonwin.mes2u8.domain.u8;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
public class U8ProductionHandlerResultInfo {

    private String inventorycode;
    private BigDecimal quantity;
    private BigDecimal number;

    public U8ProductionAddParamInfoEntry convertProductionHandlerResultInfoEntry() {
        U8ProductionAddParamInfoEntry entry = new U8ProductionAddParamInfoEntry();
        entry.setInventorycode(getInventorycode().replace("-", ""));
        // 数量
        entry.setQuantity(getQuantity().divide(new BigDecimal("1000"), 6, RoundingMode.HALF_UP));
        // 件数
        entry.setNumber(number);
        // 数量除以件数
        entry.setIrate(entry.getQuantity().divide(number, 6, RoundingMode.HALF_UP));
        return entry;
    }
}
